home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 011 / attclk2.arc / READPORT.C < prev    next >
Text File  |  1986-01-09  |  563b  |  26 lines

  1. /* :ts=8
  2.  *
  3.  *    readport()
  4.  *
  5.  * Reads a byte from the specified real time clock
  6.  * port.  Only the lower four bits are valid and a
  7.  * value of 0x0f indicates an update occured while
  8.  * reading the port.
  9.  *
  10.  */
  11.  
  12. readport(portaddr)
  13. int    portaddr;
  14. {
  15.         /* the following bit-field is used to */
  16.         /* auto-magically strip the upper 4 bits */
  17.         /* from the byte read from the port portaddr. */
  18.     struct {
  19.         unsigned value    : 4;
  20.     } port;
  21.  
  22.     while ((port.value = inportb(portaddr)) == 0x0f)
  23.         ;    /* loop until no error occurs */
  24.     return(port.value);
  25. }
  26.